package entity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TemplateGroup {

	String keyword;
	String templateKeyword;
	String showText;
	
	private List<Template> templates;
	private Map<String, Object> fieldMap;
	
	public TemplateGroup(String keyword) {
		this.keyword = keyword;
	}
	
	public String getKeyword() {
		return keyword;
	}
//	public void setKeyword(String keyword) {
//		this.keyword = keyword;
//	}
	public String getTemplateKeyword() {
		return templateKeyword;
	}
	public void setTemplateKeyword(String templateKeyword) {
		this.templateKeyword = templateKeyword;
	}
	public String getShowText() {
		return showText;
	}
	public void setShowText(String showText) {
		this.showText = showText;
	}
	public List<Template> getTemplates() {
		return templates;
	}

	public void setTemplates(List<Template> templates) {
		this.templates = templates;
	}
	
	public Map<String, Object> getFieldsMap() {
		if (this.fieldMap != null) return this.fieldMap;
		
		List<Template> templates = getTemplates();
		
		Map<String, Object> _fieldMap = new HashMap<String, Object>();
		for (Template template : templates) {
			_fieldMap.put(template.getFieldName(), template.getContent());
		}
		this.fieldMap = _fieldMap;
		return _fieldMap;
	}
	
}
